/* 
A.prepend(B) revient au même que B.prependTo(A).
A.append(B) revient au même que B.appendTo(A).
A.before(B) revient au même que B.insertBefore(A).
A.after(B) revient au même que B.insertAfter(A). 
*/

function buildHeader()
{
	console.log("buildHeader()");
	var blocPage = $(document.createElement('div')).attr("id","bloc_page");
	var header = $(document.createElement('header')).attr("id","header").appendTo(blocPage);
	var lien = $(document.createElement('a')).attr("href","index.html").appendTo(header);
	var title = $(document.createElement('div')).attr("id","titre_principal").html("TAG THIS").appendTo(lien); 
	var nav = $(document.createElement('nav')).insertAfter(lien);
	var liste =  $(document.createElement('ul')).appendTo(nav);
	$(document.createElement('img')).attr("src","images/logo.png").appendTo($(document.createElement('li')).attr("id","logo").appendTo(liste));
	$(document.createElement('a')).attr("href","world_map.html").html('Map Monde').appendTo($(document.createElement('li')).attr("id","lien_menu").appendTo(liste));
	$(document.createElement('a')).attr("href","my_friends.html").html('Mes Amis').appendTo($(document.createElement('li')).attr("id","lien_menu").appendTo(liste));
	$(document.createElement('a')).attr("href","my_comments.html").html('Mes Com\'s').appendTo($(document.createElement('li')).attr("id","lien_menu").appendTo(liste));
	$(document.createElement('a')).attr("href","my_account.html").html('Mon compte').appendTo($(document.createElement('li')).attr("id","lien_menu").appendTo(liste));
	$(document.createElement('li')).attr("id","login").appendTo(liste);	
	$('body').prepend(blocPage);
	
	//buildAuthentification();
}

function buildAuthentification()
{
	console.log('buildAuthentification()');
	var script = "(function() {";
	script +=	"var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;";
	script +=	"po.src = 'https://apis.google.com/js/client:plusone.js';";
	script +=	"var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);";
	script +=	"})();";
	escript = $(document.createElement('script')).attr('type','text/javascript').html(script);
    $('body').before(escript);
}